import { useRoutes, Navigate } from 'react-router-dom' //管理路由配置
// v6版本中引入了useRoutes来集中式管理路由配置
// 不同于v5版本需要安装react-router-config包
// v6版本我们可以直接从react-router-dom中解构导入useRoutes
import ASDiscover from '../pages/discover/index'
import ASFriend from '../pages/friend/index'
import ASMine from '../pages/mine/index'
import ASRecommend from '../pages/discover/c-pages/recommend/index'
import ASRanking from '../pages/discover/c-pages/ranking/index'
import ASSongs from '../pages/discover/c-pages/songs/index'
import ASDjRadio from '../pages/discover/c-pages/djradio/index'
import ASArtist from '../pages/discover/c-pages/artist/index'
import ASAlbum from '../pages/discover/c-pages/album/index'

const AppRoutes = () => {
  let element = useRoutes([
    {
      path: '/',
      exact: true,
      element:<Navigate to="/discover" />
      // 重定向
      // element: <ASDiscover></ASDiscover>
    },
    {
      path: '/discover',
      exact: true,
      element: <ASDiscover />,
      children:[
        {
          path:'/discover',
          exact: true,
          element: <Navigate to='/discover/recommend'/>
        },
        {
          path: 'recommend',
          exact: true,
          element:<ASRecommend/>
        },
        {
          path: 'ranking',
          exact: true,
          element: <ASRanking/>
        },
        {
          path: 'songs',
          exact: true,
          element: <ASSongs/>
        },
        {
          path: 'djradio',
          exact: true,
          element: <ASDjRadio/>
        },
        {
          path: 'artist',
          exact: true,
          element: <ASArtist/>
        },
        {
          path: 'album',
          exact: true,
          element: <ASAlbum/>
        }
      ]
    },
    {
      path: '/mine',
      element: <ASMine/>,
    },
    {
      path: '/friend',
      element: <ASFriend />,
    }
  ])
  return element
}

export default AppRoutes
